//
//  HMSpecialColumnListCtr.m
//  HowToDo
//
//  Created by 胡坤 on 2017/1/6.
//  Copyright © 2017年 KY. All rights reserved.
//

#import "HMSpecialColumnListCtr.h"
#import "HTDSpecialColumn.h"
#import "HMSCChannelView.h"
#import "HMHomeSpecialColumnCell.h"
#import "HMDetailsTableViewController.h"
@interface HMSpecialColumnListCtr ()<UITableViewDataSource,UITableViewDelegate>
/**
 展示数据的主列表视图
 */
@property(nonatomic,strong)UITableView *mainTab;
@end
@implementation HMSpecialColumnListCtr

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self setUPUI];
}
-(void)setUPUI
{
    self.mainTab.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:self.mainTab];

    [self.mainTab mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.top.equalTo(self.view);
        make.left.right.bottom.equalTo(self.view);
    }];
    [self.mainTab registerNib:[UINib nibWithNibName:@"HMHomeSpecialColumnCell" bundle:nil] forCellReuseIdentifier:@"HomeSpecialColumnCellID"];
    self.mainTab.estimatedRowHeight = 120;
}
#pragma mark --dataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.splist.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    HMHomeSpecialColumnCell * cell = [tableView dequeueReusableCellWithIdentifier:@"HomeSpecialColumnCellID" forIndexPath:indexPath];
    HTDSpecialColumn* specialColumn = self.splist[indexPath.row];
    
    cell.specialColumn = specialColumn;
    cell.selectionStyle =  UITableViewCellSelectionStyleNone;
    
    return cell;
}
#pragma mark -- delegate 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    HMDetailsTableViewController* detailVc= [[HMDetailsTableViewController alloc]init];
    HTDSpecialColumn* specialColumn  = self.splist[indexPath.row];
    detailVc.tid = specialColumn.tid;
    [self.navigationController pushViewController:detailVc animated:YES];
}
//懒加载tabview
-(UITableView *)mainTab
{
    if (!_mainTab)
    {
        _mainTab = [[UITableView alloc]init];
        _mainTab.dataSource = self;
        _mainTab.delegate = self;
    }
    return _mainTab;
}

@end
